#!/bin/bash
#
# ploned	start plone instances
#
# Author:       Ricardo Brito do Nascimento <brito[at]incolume.com.br>
#
# chkconfig:    12345 97 03
#
# description:  Start plone instances.
#
# processname: ploned


PLONE_HOME=/opt/

_start(){

echo 'iniciando o zeo...'
find $PLONE_HOME  -name "zeoctl"| while read a;
	do 
		$a start 2> /dev/null && echo -e "$a \n"; 
	done

echo 'iniciando o Plone...'
find $PLONE_HOME -name "zopectl"| while read a;
	do 
		$a start 2> /dev/null && echo -e "$a \n"; 
	done
}

_stop(){

echo 'iniciando o zeo...'
find $PLONE_HOME  -name "zeoctl"| while read a;
	do 
		$a stop 2> /dev/null && echo -e "$a \n"; 
	done

echo 'iniciando o Plone...'
find $PLONE_HOME -name "zopectl"| while read a;
	do 
		$a stop 2> /dev/null && echo -e "$a \n"; 
	done
}

_status(){


echo 'status do zeo...'
find $PLONE_HOME  -name "zeoctl"| while read a;
	do 
		$a status 2> /dev/null && echo -e "$a \n"; 
	done

echo 'status do Plone...'
find $PLONE_HOME -name "zopectl"| while read a;
	do 
		$a status 2> /dev/null && echo -e "$a \n"; 
	done
}

_restart(){

echo 'reiniciando o zeo...'
find $PLONE_HOME -name "zeoctl"| while read a;
	do 
		$a restart 2> /dev/null && echo -e "$a \n"; 
	done

echo 'reiniciando o Plone...'
find $PLONE_HOME -name "zopectl"| while read a;
	do 
		$a restart 2> /dev/null && echo -e "$a \n"; 
	done
}

_help(){
	echo -e "\n $0 {start|stop|restart|status} \n";
}
case $1 in
	'') _start;;
	start) _start;;
	stop) _stop;;
	status) _status;;
	restart) _restart;;
	-h|--help|?) _help;;
	*) echo -e "\n $0 {start|stop|restart|status} \n" ;;
esac
